package com.yixing.tech.common.convert;


import org.springframework.util.ObjectUtils;

import static java.lang.Integer.valueOf;

/**
 * The class to convert {@link String} to {@link Double}
 */
public class StringToIntegerConverter implements Converter<String, Integer> {

    @Override
    public Integer convert(String source) {
        return !ObjectUtils.isEmpty(source) ? valueOf(source) : null;
    }

    @Override
    public Class<String> getSourceType() {
        return String.class;
    }

    @Override
    public Class<Integer> getTargetType() {
        return Integer.class;
    }

}
